package top.wu2020.lazy.ws.chat.controller;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.wu.framework.web.spring.EasyController;
import org.springframework.web.bind.annotation.*;
import org.wu.framework.web.response.Result;
import org.wu.framework.web.response.ResultFactory;
import org.springframework.beans.factory.annotation.Autowired;
import jakarta.annotation.Resource;
import top.wu2020.lazy.ws.chat.domain.model.content.Content;
import top.wu2020.lazy.ws.chat.application.command.content.ContentRemoveCommand;
import top.wu2020.lazy.ws.chat.application.command.content.ContentStoryCommand;
import top.wu2020.lazy.ws.chat.application.command.content.ContentUpdateCommand;
import top.wu2020.lazy.ws.chat.application.command.content.ContentQueryListCommand;
import top.wu2020.lazy.ws.chat.application.command.content.ContentQueryOneCommand;
import top.wu2020.lazy.ws.chat.application.ContentApplication;
import top.wu2020.lazy.ws.chat.application.dto.ContentDTO;
import java.util.List;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
/**
 * describe content 
 *
 * @author Jia wei Wu
 * @date 2024/05/24 08:52 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyController 
 **/
@Tag(name = "提供者")
@EasyController("/content")
public class ContentProvider  {

    @Resource
    private ContentApplication contentApplication;

    /**
     * describe 新增
     *
     * @param contentStoryCommand 新增     
     * @return {@link Result<Content>} 新增后领域对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "新增")
    @PostMapping("/story")
    public Result<Content> story(@RequestBody ContentStoryCommand contentStoryCommand){
        return contentApplication.story(contentStoryCommand);
    }
    /**
     * describe 批量新增
     *
     * @param contentStoryCommandList 批量新增     
     * @return {@link Result<List<Content>>} 新增后领域对象集合     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "批量新增")
    @PostMapping("/batchStory")
    public Result<List<Content>> batchStory(@RequestBody List<ContentStoryCommand> contentStoryCommandList){
        return contentApplication.batchStory(contentStoryCommandList);
    }
    /**
     * describe 更新
     *
     * @param contentUpdateCommand 更新     
     * @return {@link Result<Content>} 领域对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "更新")
    @PutMapping("/updateOne")
    public Result<Content> updateOne(@RequestBody ContentUpdateCommand contentUpdateCommand){
        return contentApplication.updateOne(contentUpdateCommand);
    }
    /**
     * describe 查询单个
     *
     * @param contentQueryOneCommand 查询单个     
     * @return {@link Result<ContentDTO>} DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "查询单个")
    @GetMapping("/findOne")
    public Result<ContentDTO> findOne(@ModelAttribute ContentQueryOneCommand contentQueryOneCommand){
        return contentApplication.findOne(contentQueryOneCommand);
    }
    /**
     * describe 查询多个
     *
     * @param contentQueryListCommand 查询多个     
     * @return {@link Result<List<ContentDTO>>} DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "查询多个")
    @GetMapping("/findList")
    public Result<List<ContentDTO>> findList(@ModelAttribute ContentQueryListCommand contentQueryListCommand){
        return contentApplication.findList(contentQueryListCommand);
    }
    /**
     * describe 分页查询多个
     *
     * @param contentQueryListCommand 分页查询多个     
     * @return {@link Result<LazyPage<ContentDTO>>} 分页DTO对象     
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "分页查询多个")
    @GetMapping("/findPage")
    public Result<LazyPage<ContentDTO>> findPage(@Parameter(description ="分页大小") @RequestParam(defaultValue = "10", value = "size") int size,
                           @Parameter(description ="当前页数") @RequestParam(defaultValue = "1", value = "current") int current,@ModelAttribute ContentQueryListCommand contentQueryListCommand){
        return contentApplication.findPage(size,current,contentQueryListCommand);
    }
    /**
     * describe 删除
     *
     * @param contentRemoveCommand 删除     
     * @return {@link Result<Content>}      
     
     * @author Jia wei Wu
     * @date 2024/05/24 08:52 晚上
     **/

    @Operation(summary = "删除")
    @DeleteMapping("/remove")
    public Result<Content> remove(@ModelAttribute ContentRemoveCommand contentRemoveCommand){
        return contentApplication.remove(contentRemoveCommand);
    }
}